package com.tsing.wms.vo.req;

import com.tsing.wms.valid.AddGroup;
import com.tsing.wms.valid.UpdateGroup;
import com.tsing.wms.valid.ValidList;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.Valid;
import javax.validation.constraints.*;

/**
 * @author TheTsing
 * @create 2022-04-16 12:25
 */
@Data
public class OrderReqVO {

    @Null(message = "新增时不能传入id", groups = {AddGroup.class})
    @NotBlank(message = "id不能为空", groups = {UpdateGroup.class})
    private String id;

    @ApiModelProperty("供应商id")
    @NotBlank(message = "供应商id不能为空", groups = {AddGroup.class})
    private String supplierId;

    @ApiModelProperty("下单人员id")
    @NotBlank(message = "下单人员id不能为空", groups = {AddGroup.class})
    private String userId;

    @ApiModelProperty("订单状态 1 已下单  2 已发货  3 已接收  4 已入库")
    @Null(message = "新增时不能传入订单状态", groups = {AddGroup.class})
    @Range(min = 1, max = 4, message = "只能传入1~4，1 已下单  2 已发货  3 已接收  4 已入库", groups = {UpdateGroup.class})
    private Integer status;

    @ApiModelProperty("描述")
    private String description;

    @Valid
    @ApiModelProperty("订单清单")
    @NotEmpty(message = "至少包含一个订单清单", groups = {AddGroup.class, UpdateGroup.class})
    private ValidList<OrderDetailReqVO> orderDetails;

    @Data
    public static class OrderDetailReqVO {

        @ApiModelProperty("货物id")
        @NotBlank(message = "货物id不能为空", groups = {AddGroup.class, UpdateGroup.class})
        private String goodsId;

        @ApiModelProperty("数量")
        @NotNull(message = "数量不能为空", groups = {AddGroup.class, UpdateGroup.class})
        @DecimalMin(value = "1", message = "数量不能小于1", groups = {AddGroup.class, UpdateGroup.class})
        private Integer amount;

    }

}
